﻿#include "stdafx.h"
#include "CLIFactories.h"

using namespace System;
using namespace System::Collections::Generic;

namespace $RootNamespace$
{

	void CLIClient::Test()
	{
	
		// Abstract factory #1
	
		CLIAbstractFactory ^factory1 = gcnew $ConcreteFactory1$();
	
		CLIClient ^client1 = gcnew CLIClient(factory1);
	
		client1->Run();
	
	
	
		// Abstract factory #2
	
		CLIAbstractFactory ^factory2 = gcnew $ConcreteFactory2$();
	
		CLIClient ^client2 = gcnew CLIClient(factory2);
	
		client2->Run();

	}

	CLIClient::CLIClient(CLIAbstractFactory ^factory)
	{
	
		_$AbstractProductB$ = factory->CreateProductB();
	
		_$AbstractProductA$ = factory->CreateProductA();
	
	}

	void CLIClient::Run()
	{
	
		_$AbstractProductB$->Interact(_$AbstractProductA$);
	
	}

	$AbstractProductA$ ^$ConcreteFactory1$::CreateProductA()
	
	{
	
	  return gcnew $ProductA1$();
	
	}

	$AbstractProductB$ ^$ConcreteFactory1$::CreateProductB()
	
	{
	
	  return gcnew $ProductB1$();
	
	}

	$AbstractProductA$ ^$ConcreteFactory2$::CreateProductA()
	
	{
	
	  return gcnew $ProductA2$();
	
	}

	$AbstractProductB$ ^$ConcreteFactory2$::CreateProductB()
	
	{
	
	  return gcnew $ProductB2$();
	
	}
}